package com.smartscreen.schedulemanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartscreen.schedulemanage.entity.ExamSchedule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ExamScheduleMapper extends BaseMapper<ExamSchedule> {
    
    @Select("SELECT DISTINCT es.* FROM exam_schedule es " +
            "LEFT JOIN exam_grade_relation egr ON es.exam_id = egr.exam_id " +
            "WHERE (#{termId} IS NULL OR es.term_id = #{termId}) " +
            "AND (#{gradeId} IS NULL OR egr.grade_id = #{gradeId})")
    List<ExamSchedule> getExamSchedules(@Param("termId") String termId, @Param("gradeId") String gradeId);
}